package com.zhanghe.study.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ForwardServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("ForwardServlet..");
        // 进行请求转发  path需要加上/
        // 否则url地址只会截掉一个/后的路径然后拼接该地址，变成localhost:8080/webstudy/test/forwardServlet会转发到localhost:8080/webstudy/test/test/testServlet
        req.getRequestDispatcher("/test/testServlet").forward(req,resp);
    }
}
